package cate.game.play.skill.passive.god;

import cate.common.table.d.GDBuff;
import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 攻击时有16%概率驱散对方至多1个单位觉醒状态
 */
public class 破灭PH extends PassiveHandler {

	private int 概率;

	private int 人数;

	//概率=1600&人数=1
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		人数 = args.getInt("人数", 1);
	}

	@Override
	public void onSkillDone(SkillActionCtx action) {
		if (XT.isBlank(action.getTargets())) {
			return;
		}
		if(!action.getSkill().cfg.isHurtSkill()){
			return;
		}
		if (!XT.chance(概率)) {
			return;
		}
		for (Fighter target : XT.randomPick(action.getTargets(), 人数, true)) {
			target.buff.removeBuff(action, b -> b.cfg.isEffectType(GDBuff.Type.英雄觉醒));
		}
	}
}
